<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./write.js"></script>
  </head>
  <body>
    <script>
      const p1 = new MyPromise((resolve, reject) => {
        setTimeout(() => {
          resolve("ok");
          reject("error");
        }, 2000);
        // resolve("ok");
      });
      console.log(p1);

      const p2 = p1.then(
        (val) => {
          console.log(val);
        },
        (rea) => {
          console.log(rea);
        }
      );

      console.log(p2);
    </script>
  </body>
</html>
